//
//  ViewController.m
//  ZBOpenGLESDemo
//
//  Created by apple on 2018/7/11.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "ViewController.h"
#import "ZBViewController01.h"
#import "ZBViewController02.h"

static NSString *cellID = @"cellID";
@interface ViewController ()

@property (nonatomic, strong) NSMutableArray <NSString *> *dataSource;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:cellID];
}



#pragma mark - tableView
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.dataSource.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if(indexPath.row < self.dataSource.count){
       NSString *str =  self.dataSource[indexPath.row];
        cell.textLabel.text = str;
    }
    return cell;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    switch (indexPath.row) {
        case 0:
            {
                ZBViewController01 *vc = [[ZBViewController01 alloc]init];
                vc.title = self.dataSource[indexPath.row];
                [self.navigationController pushViewController:vc animated:YES];
            }
            break;
        case 1:
        {
            ZBViewController02 *vc = [[ZBViewController02 alloc]init];
            vc.title = self.dataSource[indexPath.row];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
            
            
            
        default:
            break;
    }
}


#pragma mark - lazy
- (NSMutableArray<NSString *> *)dataSource
{
    if(_dataSource == nil)
    {
        _dataSource = [NSMutableArray array];
        //1.初始OpenGLES
        [_dataSource addObject:@"01-初始OpenGLES-显示图片"];
        
        //2.画板签名
        [_dataSource addObject:@"02-画板签名"];
        
    }
    return _dataSource;
}
@end
